Skip to main content

VectorSpace

Initialize the VectorSpace class.

import vecto
vector_space = vecto.VectorSpace("my-cool-image-ai")

Args:

  • name (str): The name of the vector space. If multiple vector spaces have the same name, will return the first instance.
  • token (str, optional): The API token
  • modality (str, optional): The modality of the vector space (TEXT or IMAGE)

Methods

exists

exists(self) -> bool

Check if the vector space exists.

Returns:

bool: True if the vector space exists, False otherwise


create

create(self, model: str, modality: str = None)

Create a new vector space.

Args:

  • model (str): The name of the model to be used
  • modality (str, optional): The modality of the vector space (TEXT or IMAGE), defaults to None

lookup

lookup(self, query: IO, top_k: int, ids: list = None, **kwargs) -> List[LookupResult]

Perform a lookup query on the vector space.

Args:

  • query (IO): The query as an IO object
  • top_k (int): The number of results to return
  • ids (list, optional): A list of vector ids to search on (subset of vectors), defaults to None

Returns:

list of LookupResult: A list of LookupResult named tuples containing 'data', 'id', and 'similarity' keys


lookup_image

lookup_image(self, query, top_k: int, ids: list = None, **kwargs) -> List[LookupResult]

Perform an image lookup query on the vector space.

Args:

query: The image query (URL, filepath, or IO object)

  • top_k (int): The number of results to return
  • ids (list, optional): A list of vector ids to search on (subset of vectors), defaults to None

Returns:

list of LookupResult: A list of LookupResult named tuples containing 'data', 'id', and 'similarity' keys


lookup_text

lookup_text(self, query, top_k: int, ids: list = None, **kwargs) -> List[LookupResult]

Perform a text lookup query on the vector space.

Args:

query: The text query (string, path-like object, or IO object)

  • top_k (int): The number of results to return
  • ids (list, optional): A list of vector ids to search on (subset of vectors), defaults to None

Returns:

list of LookupResult: A list of LookupResult named tuples containing 'data', 'id', and 'similarity' keys


ingest_image

ingest_image(self, image_path: str, attribute: str, **kwargs) -> IngestResponse

Ingest an image into the vector space.

Args:

  • image_path (str): The path of the image to ingest
  • attribute (str): The attribute associated with the image

Returns:

IngestResponse: An IngestResponse object containing the response data


ingest_text

ingest_text(self, text: str, attribute: str, **kwargs) -> IngestResponse

Ingest text into the vector space.

Args:

  • text (str): The text to ingest
  • attribute (str): The attribute associated with the text

Returns:

IngestResponse: An IngestResponse object containing the response data


compute_text_analogy

compute_text_analogy(self, query: IO, analogy_start_end: Union[VectoAnalogyStartEnd, List[VectoAnalogyStartEnd]], top_k: int, **kwargs) -> List[LookupResult]

Compute text analogy on the vector space.

Args:

  • query (IO): The query as an IO object
  • analogy_start_end (Union[VectoAnalogyStartEnd, List[VectoAnalogyStartEnd]]): The start and end points of the analogy
  • top_k (int): The number of results to return
  • **kwargs: Other keyword arguments

Returns:

list of LookupResult: A list of LookupResult named tuples containing 'data', 'id', and 'similarity' keys


compute_image_analogy

compute_image_analogy(self, query: IO, analogy_start_end: Union[VectoAnalogyStartEnd, List[VectoAnalogyStartEnd]], top_k: int, **kwargs) -> List[LookupResult]

Compute image analogy on the vector space.

Args:

  • query (IO): The query as an IO object
  • analogy_start_end (Union[VectoAnalogyStartEnd, List[VectoAnalogyStartEnd]]): The start and end points of the analogy
  • top_k (int): The number of results to return

Returns:

list of LookupResult: A list of LookupResult named tuples containing 'data', 'id', and 'similarity' keys


clear_entries

clear_entries(self, **kwargs)

Clear all entries in the vector space.